<template>
  <div class="comment-container">
    <el-card class="box-card">
      <!-- 表格 -->
      <el-table
        :data="applyShopList"
        style="width: 100%"
        stripe
        lazy
        >>
        <el-table-column type="selection" width="50"> </el-table-column>
        <el-table-column prop="name" label="姓名" width="100" align="center"> </el-table-column>
        <el-table-column prop="phone" label="手机" align="center"> </el-table-column>
        <el-table-column prop="idCard" label="身份证号"  align="center"> </el-table-column>
        <el-table-column prop="address" label="地址"  align="center"> </el-table-column>
        <el-table-column
          prop="createdAt"
          label="时间"
          width="160"
          align="center"
        >
        </el-table-column>
        <el-table-column prop="stutas" label="状态" width="80" align="center">
          <template v-slot="slot">
            <!-- 1:审核中;2:审核通过;3审核失败;) -->
            <el-tag type="info" v-if="slot.row.status==1">审核中</el-tag>
            <el-tag type="success" v-else-if="slot.row.status==2">审核通过</el-tag>
            <el-tag type="danger" v-else>审核失败</el-tag>
          </template>
        </el-table-column>
      
        <el-table-column prop="address" label="操作" width="85" align="center">
          <template v-slot="slot">
            <el-button
              type="primary"
              icon="el-icon-edit"
              size="small"
              @click="auditClick(slot.row)"
              >审核</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <!-- 分页 -->
      <el-pagination
        background
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="queryInfo.pageNum"
        :page-sizes="[5, 10, 15, 20]"
        :page-size="queryInfo.pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      >
      </el-pagination>
    </el-card>
    <!-- 审核对话框 -->
    <el-dialog
  title="审核信息"
  :visible.sync="auditDialogVisible"
  width="30%"
   center
  :before-close="handleClose">
  <el-radio-group v-model="radio">
    <el-radio :label="1">审核中</el-radio>
    <el-radio :label="2">审核通过</el-radio>
    <el-radio :label="3">审核失败</el-radio>
  </el-radio-group>
  <el-input
  type="textarea"
  placeholder="请输入内容"
  v-model="desc"
>
</el-input>
  <span slot="footer" class="dialog-footer">
    <el-button @click="auditDialogVisible = false">取 消</el-button>
    <el-button type="primary" @click="auditOk">确 定</el-button>
  </span>
</el-dialog>
  </div>
</template>

<script>
import { getApplyShop ,getApplyShopId,auditApplyShop} from "@/api/admin/shop";
export default {
  name: "Comment",
  data() {
    return {
      applyShopList: [], // 文章表格数据
      queryInfo: {
        query: "", // 查询参数
        pageNum: 1, // 分页页码
        pageSize: 10, // 页面数据条数
      },
      total: 0,
      auditDialogVisible: false,
      radio:1,
      rows:{},
      desc:'',
    };
  },
  created() {
    this.getApplyShop();
  },
  methods: {
      // 点击审核
   async auditClick(row) {
     const res = await getApplyShopId(row.id)
     this.radio = res.status
     this.rows = res
      this.auditDialogVisible = !this.auditDialogVisible
    },
   async auditOk(){
     const id =  this.rows.id
     const body =  this.radio
      await auditApplyShop(id,{ status: body,desc: this.desc})
       this.auditDialogVisible = !this.auditDialogVisible
       this.getApplyShop();
      const res = await getApplyShopId(id)
      switch (res.status) {
		case 1:
			this.$message.info('审核状态为：审核中')
		break
		case 2:
			this.$message.success('审核状态为：审核通过')
		break
	  case 3:
			this.$message.warning('审核状态为：审核失败')
		break
	}
    },
    handleClose(done){
       done();
    },
    // 数据
    async getApplyShop() {
      const { list, pageNum, pageSize, total } = await getApplyShop(
        this.queryInfo
      );
      this.applyShopList = list;
      this.queryInfo.pageNum =Number(pageNum);
      this.queryInfo.pageSize =Number(pageSize);
      this.total = total;
    },
    // 设置页面数据条数
    handleSizeChange(val) {
      this.queryInfo.pageSize = val;
      this.getApplyShop();
    },
    // 设置分页页码
    handleCurrentChange(val) {
      this.queryInfo.pageNum = val;
      this.getApplyShop();
    },
  },
};
</script>

<style lang="scss">
.el-select .el-input {
  width: 80px;
}
.box-card {
  margin: 20px;
}
.el-table {
  margin: 20px 0px;
}
.el-textarea{
  margin-top: 30px;
}
</style>
